package com.ihome.excel.xlsx.exceptions;

import com.ihome.excel.xlsx.engine.export.ExcelRuleValidate;

public enum ThrowableDefine {

    PARAMETER_VALIDATE_EXP(100, "%s不能为空"),

    MAPPING_ENTITY_DEFINE_ERROR(200, "数据导入文件没有配置映射对象"),
    
    MAPPING_KEY_NO_DEFINE(201,"数据导入文件没有配置映射键"),
    
    MAPING_ENTITY_PATH_ERROR(202,"数据导入文件配置的映射对象路径错误:[%s]"),
    
    MAPING_ATTRIBUTE_NO_DEFINE(203,"属性未在[%s]类中定义:属性名称[%s]"),

    CELL_VALUE_TYPE_NOT_MISMATCH(300,"Excel数据类型错误:第[%s]行,第[%s]列,定义数据类型[%s],单元格数据类型[%s]"),
    
    CELL_VALUE_NOT_EMPTY(301,"Excel数据类型错误:第[%s]行,第[%s]列不能为空"),
    
    CELL_VALUE_LENGTH_GT(302,"Excel数据类型错误:第[%s]行,第[%s]列长度必须大于[%s]"),
    
    CELL_VALUE_LENGTH_LT(303,"Excel数据类型错误:第[%s]行,第[%s]列长度必须小于[%s]"),
    
    CELL_VALUE_UNRECOGNIZED(304,"无法识别的数据类型:[%s]"),
    
    CELL_VALUE_NOT_EMAIL(305,"Excel数据类型错误:第[%s]行,第[%s]列必须是邮件地址"),
    
    CELL_VALUE_NOT_IDCARD(306,"Excel数据类型错误:第[%s]行,第[%s]列必须是身份证号"),
    
    CELL_VALUE_NOT_MOBILE(307,"Excel数据类型错误:第[%s]行,第[%s]列必须是手机号"),
    
    CELL_VALUE_NOT_PHONE(308,"Excel数据类型错误:第[%s]行,第[%s]列必须是座机号"),
    
    CELL_VALUE_LENGTH_EQUALS(309,"Excel数据类型错误:第[%s]行,第[%s]列长度必须等于[%s]"),
    
    SHEET_CLASSA_REFLECTION_ERROR(400,"映射对象反射实例化异常:[%s]"),
    
    PROPERTIES_LOAD_ERROR(500,"属性文件加载异常:[%s]"),
	
	EXCEL_RULE_VALIDATE_ERROR(600,"[%s]配置不能为空"),
	
	EXCEL_RULE_MAPPING_EROOR(601,"映射对象配置有误:[%s]"),
	
	EXCEL_RULE_ATTRIBUTE_ERROR(602,"属性配置[%s]在实体[%s]不存在对应的映射方法"),
	
	EXCEL_RULE_NOT_EXISTS(603,"对应规则配置[%s]在excel-write-rule.xml文件中没打到");
    
    private ThrowableDefine(int code, String message) {
        this.code = code;
        this.message = message;
    }

    private int code;
    private String message;

    public int getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }

    public IllegalArgumentException getIllegaArgumentExp(Object... args) {
        return new IllegalArgumentException(String.format(this.message, args));
    }
    
    public TemplateParseException getTemplateParseExp(){
        return new TemplateParseException(this.getMessage());
    }
    
    public TemplateParseException getTemplateParseExp(Object... args) {
        return new TemplateParseException(String.format(this.message, args));
    }
    
    public CellValidateException getCellValidateExp(Object... args){
        return new CellValidateException(String.format(this.message, args));
    }
    
    public SheetValidateException getSheetValidateException(Object... args){
        return new SheetValidateException(String.format(this.message, args));
    }
    
    public PropertiesLoadException getPropertiesLoadExp(Object... args){
        return new PropertiesLoadException(String.format(this.message, args));
    }
    
    public ExcelRuleValidateException getExcelRuleValidateExp(Object... args) {
    	return new ExcelRuleValidateException(String.format(this.message, args));
    }
    
    public ExcelWriteException getExcelWriteException(Object... args) {
    	return new ExcelWriteException(String.format(this.message, args));
    }
    
}
